const mongoose = require('mongoose')
const Pand = require("./pandant")
const userSchema = new mongoose.Schema({
  email: {
    type: String,
    maxlength: 30,
    minlength: 4,
    required: [true, "填写邮箱"]
  },
  username: {
    type: String,
    maxlength: 20,
    minlength: 2,
    required: [true, "填写姓名2~20"]
  },
  password: {
    type: String,
    maxlength: 1000,
    minlength: 4,
    required: [true, '填写密码']
  },
  headerimg: {
    type: String,
    default: "http://127.0.0.1:8888/user/user.jpg"
  },
  identity: { //用户身份 admin/teacher/student 
    type: String,
    default: "student"
  },
  member:{  //是否是会员
    type:Boolean,
    default:false
  },
  membertime:{  //会员过期时间，时间戳
    type:Number,
  },
  pand_url: {
    type: String,
    default: ""
  },
  flutter_number: { //用户界面灰度值
    type: Number,
    default: 0.01
  },
  user_music_isplay: {
    type: Boolean,
    default: false
  },
  user_grade_arr: {
    type: Array,
    default: [
      {
        value:0,
        describe:"学前教育"
      }, 
      {
        value:1,
        describe:"一年级"
      },
      {
        value:2,
        describe:"二年级"
      },
      {
        value:3,
        describe:"三年级"
      },
      {
        value:4,
        describe:"四年级"
      },
      {
        value:5,
        describe:"五年级"
      },
      {
        value:6,
        describe:"六年级"
      },  {
        value:7,
        describe:"七年级"
      },
      {
        value:8,
        describe:"八年级"
      },
      {
        value:9,
        describe:"九年级"
      },
       {
        value:10,
        describe:"高一"
      },
      {
        value:11,
        describe:"高二"
      },
      {
        value:12,
        describe:"高三"
      },

]
 
  },
  user_project_arr: {
    type: Array,
    default: [{
        value: "1",
        label: "语文",
        children: [{
            value: "1",
            label: "班级排名",
          },
          {
            value: "2",
            label: "校排名",
          },
          {
            value: "3",
            label: "区排名",
          },
        ],
      },
      {
        value: "2",
        label: "数学",
        children: [{
            value: "1",
            label: "班级排名",
          },
          {
            value: "2",
            label: "校排名",
          },
          {
            value: "3",
            label: "区排名",
          },
        ],
      },
      {
        value: "3",
        label: "外语",
        children: [{
            value: "1",
            label: "班级排名",
          },
          {
            value: "2",
            label: "校排名",
          },
          {
            value: "3",
            label: "区排名",
          },
        ],
      },

      {
        value: "4",
        label: "政治",
        children: [{
            value: "1",
            label: "班级排名",
          },
          {
            value: "2",
            label: "校排名",
          },
          {
            value: "3",
            label: "区排名",
          },
        ],
      },
      {
        value: "5",
        label: "历史",
        children: [{
            value: "1",
            label: "班级排名",
          },
          {
            value: "2",
            label: "校排名",
          },
          {
            value: "3",
            label: "区排名",
          },
        ],
      },
      {
        value: "6",
        label: "地理",
        children: [{
            value: "1",
            label: "班级排名",
          },
          {
            value: "2",
            label: "校排名",
          },
          {
            value: "3",
            label: "区排名",
          },
        ],
      },
      {
        value: "7",
        label: "物理",
        children: [{
            value: "1",
            label: "班级排名",
          },
          {
            value: "2",
            label: "校排名",
          },
          {
            value: "3",
            label: "区排名",
          },
        ],
      },
      {
        value: "8",
        label: "化学",
        children: [{
            value: "1",
            label: "班级排名",
          },
          {
            value: "2",
            label: "校排名",
          },
          {
            value: "3",
            label: "区排名",
          },
        ],
      },
      {
        value: "9",
        label: "生物",
        children: [{
            value: "1",
            label: "班级排名",
          },
          {
            value: "2",
            label: "校排名",
          },
          {
            value: "3",
            label: "区排名",
          },
        ],
      }
    ]
  },
  registerDate: { //注册时间
    type: Date,
    default: Date.now //默认值
  }
})

// 创建集合
const User = mongoose.model('User', userSchema);

// 将用户集合做为模块成员进行导出
module.exports = User